import requests, app
import unittest

class Bm(object):
    def __init__(self):
        self.url_bm = app.BASE_URL + "/api/company/department"

    def query_bm_list(self, headers):
        return requests.get(url=self.url_bm, headers=headers)

    def add_bm(self, headers, jsonData):
        return requests.post(url=self.url_bm,
                             headers=headers,
                             json=jsonData)

    def query_bm(self, headers, id):
        url_query = self.url_bm + "/" + id
        print("查询部门的URL为:", url_query)
        return requests.get(url=url_query,
                            headers=headers)

    def update_bm(self, headers, jsonData, id):
        url_modify = self.url_bm + "/" + id
        print("修改部门的URL为:", url_modify)
        return requests.put(url=url_modify,
                            headers=headers,
                            json=jsonData)

    def delete_bm(self, headers, id):
        url_delete = self.url_bm + "/" + id
        print("删除部门的URL为:", url_delete)
        return requests.delete(url=url_delete, headers=headers)
